<?php
/**
 * 用户相关
 * 
 * @package ews
 * @ews Enterprise WorkShop
 * @version 1.0 alpha
 * @since 2011-05-03
 * @author monkee
 */

class userApp extends app
{
	public function login(){
		$data = $this->getData('post');
		if(empty($data)){
			
			return array();
		}
		$usermod = & $this->getModel('user');
		$r = $usermod->login($data['email'], $data['password']);
		if($r > 0){
			//header('location:/home');
			//exit;
			return array('code' => 'succ');
		}else{
			switch ($r){
				case -1 : $this->inner_msg('email地址有误！');
				case -2 : $this->inner_msg('该用户不存在!');
				case -3 : $this->inner_msg('用户密码错误！');
			}
		}
	}
	public function add(){
		$data = $this->getData('post');
		if(empty($data)){
			return array('excute' => 0);
		}
		$usermod = & $this->getModel('user');
		$id = $usermod->add($data['email'], $data['password'], $data['username'], 1);
		return array('excute' => $id);
	}
	
	public function updatedoing(){
		$data = $this->getData('post/message');
		$data = trim($data);
		if(strlen($data) > 250){
			return array('code' => 1, 'msg' => '输入的字符长度太长啦');
		}
		$doingobj = & $this->getModel('doing');
		$id = $doingobj->update($this->user_id, $data);
		//feed
		$feedobj = & $this->getModel('feed');
		$feedobj->publish($this->user_id, $this->user['username'], 1, $data, $id);	//publish($user_id, $username, $type, $message){
		return array('code' => 0);
	}
	public function test(){
		$usermod = & $this->getModel('user');
		$usermod->login('zomboo1@126.com', '123456');
	}
}
?>